<?php
loadTemp("admin/models/member/member_header.php");
?>
<script type="text/javascript">
$(document).ready(function(){
	loadAdminTopItem();
	activeAdminTopItem("s_c_ban_user");
});
</script>
<?php checkAdminPermission("admin.member.ban_user","admin.class.*");?>
<!-- Start -->
<script type="text/javascript">
$(document).ready(function(){
	$("#form_edit_user_ban").hide();
	$("#form_ban_search").show();
	bindAjaxForm($("#form_ban_search"),s_banuser_onSuccess,s_banuser_onError,"admin_di");
	bindAjaxForm($("#form_edit_user_ban"),s_banuser_onSuccess,s_banuser_onError,"admin_di");
});
function s_banuser_onSuccess(data){
	console.log(data);
	s_banuser_operatedone(data.code,data.message,data.data);
}
function s_banuser_onError(data){
	console.log(data);
	s_banuser_operatedone(-101,"服务器返回了未知的数据，请上报管理员",data.responseText);
}
function s_banuser_operatedone(id,message,data){
	if(id==-101){
		showMessage("s_banuser_message",-101,message+"<br><br><pre>"+data+"</pre>");
		return;
	}
	if(id!=0&&id!=3){
		showMessage("s_banuser_message",id,message);
	}
	if(id==0){
		showMessage("s_banuser_message",id,message);
	}
	if(data.op=="user_search"){
		$("#form_ban_search").hide();
		$(".s_uid").attr("value",data.uid);
		s_b_loadBan(data.bandata);
		$("#form_ban_search").hide();
		$("#form_edit_user_ban").show();
	}
	if(data.op=="reset"){
		$("#form_ban_search").show();
		$("#form_edit_user_ban").hide();
	}
}
function s_b_loadBan(data){
	$("#s_name").attr("value",data.name);
	  setRadiobox(data.isbanned, "c_");
	  if(data.isbanned==1){
			$("#bantime").html("封禁状态 截至日期："+ data.bantime);
	  }else{
			  $("#bantime").html("封禁状态");
	  }
}
</script>
<div class="s_admin_in_container">
	<h2 class="ui dividing header">封禁/解封用户</h2>
	<div class="ui message">
		<div class="header">小提示</div>
		<ul class="list">
			<li>你可以在这里封禁/解封用户</li>
		</ul>
	</div>
	<div class="ui message hidden" id="s_banuser_message"></div>
	<form class="ui form admin_form" url="admin.php?mod=member&ajax=true&op=search_ban_user" id="form_ban_search">
		<div class="ui action fluid input">
			<div class="ui left icon input">
				<input type="text" name="account" placeholder="目标账号" id="s_ban_search">
				<i class="users icon"></i>
			</div>
			<button class="ui button submit" type="submit">确定</button>
		</div>
	</form>
	<form class="ui form admin_form" url="admin.php?mod=member&ajax=true&op=ban_user" id="form_edit_user_ban">
		<h4 class="ui dividing header">用户封禁查询和更改</h4>
		<input type="hidden" class="s_uid" name="uid">
		<div class="field disabled">
			<label>姓名：</label>
			<input type="text" name="name" placeholder="name" id="s_name">
		</div>
		<div class="inline fields">
			<div class="field">
				<label>封禁状态：</label>
				<div class="ui radio checkbox" id="c_false">
					<input type="radio" name="isBanned" value="0" class="hidden">
					<label>正常状态</label>
				</div>
			</div>
			<div class="field">
				<div class="ui radio checkbox" id="c_true">
					<input type="radio" name="isBanned" value="1" class="hidden">
					<label id="bantime"> 封禁状态 </label>
				</div>
			</div>
		</div>
		<div class="field">
			<label>封禁日期：</label>
			<input type="datetime-local" name="bantime" id="s_banTime">
		</div>
		<button type="submit" class="ui submit button">提交</button>
	</form>
</div>